home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / gamma-bros.swf / scripts / __Packages / classes / fx / ShrapnelB.as < prev    next >
Encoding:
Text File  |  2011-10-17  |  2.7 KB  |  96 lines

  1. class classes.fx.ShrapnelB
  2. {
  3.    var x;
  4.    var y;
  5.    var dir;
  6.    var id;
  7.    var clip;
  8.    var xMov;
  9.    var yMov;
  10.    var rotateVar;
  11.    var rotateInt;
  12.    var yank;
  13.    var c = 0;
  14.    var Name = "shrapnelB";
  15.    function ShrapnelB(px, py, pdir, pid)
  16.    {
  17.       this.x = px;
  18.       this.y = py;
  19.       this.dir = pdir;
  20.       this.id = pid;
  21.       _root.d = _root.d + 1;
  22.       this.clip = _root.attachMovie("shrapnelB","shrapnelB" + this.id + "Clip",_root.d + 75000);
  23.       this.clip._x = this.x;
  24.       this.clip._y = this.y;
  25.       if(this.dir == "U")
  26.       {
  27.          this.xMov = _root.randRange2(-6,6);
  28.          this.yMov = _root.randRange2(-6,0);
  29.       }
  30.       else if(this.dir == "D")
  31.       {
  32.          this.xMov = _root.randRange2(-6,6);
  33.          this.yMov = _root.randRange2(0,6);
  34.       }
  35.       else if(this.dir == "L")
  36.       {
  37.          this.xMov = _root.randRange2(-6,0);
  38.          this.yMov = _root.randRange2(-6,6);
  39.       }
  40.       else
  41.       {
  42.          this.xMov = _root.randRange2(0,6);
  43.          this.yMov = _root.randRange2(-6,6);
  44.       }
  45.       this.rotateVar = random(2) <= 0 ? -1 : 1;
  46.       this.rotateInt = _root.randRange(3,7);
  47.    }
  48.    function main()
  49.    {
  50.       this.c = this.c + 1;
  51.       if(this.c / this.rotateInt == Math.round(this.c / this.rotateInt))
  52.       {
  53.          this.clip._rotation += 90 * this.rotateVar;
  54.       }
  55.       if(this.clip.hitTest(_root[_root.char + "Clip"]))
  56.       {
  57.          _root.createExploA([this.x + this.clip._width / 2,this.y + this.clip._height / 2,_root.randRange(30,60),_root.randRange(70,100)]);
  58.          _root[_root.char].hit(this.xMov,this.yMov,100,15);
  59.          this.yank = true;
  60.       }
  61.       var _loc4_ = 0;
  62.       var _loc6_ = _root.broShots.length;
  63.       while(_loc4_ < _loc6_)
  64.       {
  65.          var _loc5_ = _root.broShots[_loc4_] + "Clip";
  66.          if(this.clip.hitTest(_root[_loc5_]))
  67.          {
  68.             _root.createExploA([this.x,this.y,_root.randRange(30,70),_root.randRange(75,100)]);
  69.             _root[_root.char].fc = _root[_root.char].fireFreq - _root.rapidVar - 1;
  70.             var _loc3_ = _root.broShots[_loc4_];
  71.             _root[_loc3_].exploX = this.x + this.clip.body._width / 2;
  72.             _root[_loc3_].exploY = this.y + this.clip.body._height / 2;
  73.             _root[_loc3_].hit();
  74.             this.yank = true;
  75.             break;
  76.          }
  77.          _loc4_ = _loc4_ + 1;
  78.       }
  79.       if(this.c > 100)
  80.       {
  81.          if(this.x > 1050 || this.x < -50 || this.y < -50 || this.y > 650)
  82.          {
  83.             this.yank = true;
  84.          }
  85.       }
  86.       if(this.yank)
  87.       {
  88.          _root.removeFX("shrapnelB" + this.id);
  89.       }
  90.       this.x += this.xMov;
  91.       this.y += this.yMov;
  92.       this.clip._x = this.x;
  93.       this.clip._y = this.y;
  94.    }
  95. }
  96.